package com.sw.youvote.server;

import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.sw.youvote.server.persistentobjects.QuizDAO;
import com.sw.youvote.server.persistentobjects.QuizJdoDAO;
import com.sw.youvote.shared.objects.CandidatureBean;
import com.sw.youvote.shared.objects.QuizBean;
import com.sw.youvote.client.services.QuizService;

public class QuizServiceImpl extends RemoteServiceServlet implements QuizService {
    private static final long serialVersionUID = 1L;
    //private ContactDAO contactDAO = new ContactDAOMock();
    private QuizDAO quizDAO = new QuizJdoDAO();

    public void addQuiz(QuizBean quiz) {
        quizDAO.addQuiz(quiz);
    }

    public List<QuizBean> listQuizs() {
        List<QuizBean> listQuizs = quizDAO.listQuizs();
        return new ArrayList<QuizBean> (listQuizs);
    }

    public void removeQuiz(QuizBean quiz) {
        quizDAO.removeQuiz(quiz);
    
    }

    public void updateQuiz(QuizBean quiz) {
        quizDAO.updateQuiz(quiz);
    }
    
    @Override
	public void addCandidature(QuizBean quiz, CandidatureBean candidature) {

		quizDAO.addCandidature(quiz, candidature);

	}

	@Override
	public List<CandidatureBean> listCandidatures(QuizBean quiz) {
		List<CandidatureBean> listCandidatures = quizDAO.listCandidatures(quiz);
		return new ArrayList<CandidatureBean>(listCandidatures);
		
	}

	@Override
	public void removeCandidature(QuizBean quiz, CandidatureBean candidature) {
		quizDAO.removeCandidature(quiz, candidature);


	}

	@Override
	public void updateCandidature(QuizBean quiz, CandidatureBean candidature) {
		quizDAO.updateCandidature(quiz, candidature);


	}
    

}
